<form lay-filter="addProductionPlanFormDiv" class="layui-form open-form">
    <div class="open-model" id="addProductionPlanFormContent">
        <div class="open-auto">
            <table id="productionProgressFormTable" lay-filter="productionProgressFormTable"></table>
            <div class="layui-tab layui-tab-brief" lay-filter="test-hash">
                <ul class="layui-tab-title">
                    <li class="layui-this" lay-id="11">按工序</li>
                    <li lay-id="22">按制造令</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <table id="processReportDetailTable" lay-filter="processReportDetailTable"></table>
                    </div>
                    <div class="layui-tab-item">
                        <table id="planRecordReportDetailTable" lay-filter="planRecordReportDetailTable"></table>
                    </div>
                </div>
            </div>
        </div>
</form>

<script>
    layui.use(["form", "table", "admin", "jquery", "laydate"], async function () {
        let form = layui.form;
        let table = layui.table;
        let admin = layui.admin;
        let $ = layui.jquery;
        let laydate = layui.laydate;
        const nowData = { ...parentData };
        console.log('nowData', nowData);
        table.render({
            elem: "#productionProgressFormTable",
            data: nowData.data ? [nowData.data] : [],
            cols: [
                [
                    {
                        field: "skuCode",
                        title: "在制品料号",
                        align: "center"
                    },
                    {
                        field: "skuName",
                        title: "在制品名称",
                        align: "center"
                    },
                    {
                        field: "skuSpec",
                        title: "规格",
                        align: "center"
                    },
                    {
                        field: "recordCount",
                        title: "制造令数量",
                        align: "center"
                    },
                    {
                        field: "productionQuantity",
                        title: "订单需求数量",
                        align: "center"
                    },
                    {
                        field: "inventoryQuantity",
                        title: "在库库存数量",
                        align: "center"
                    },
                    {
                        field: "productionPlanQuantity",
                        title: "总排产量",
                        align: "center"
                    },
                    {
                        field: "reportQuantity",
                        title: "总报工数",
                        align: "center"
                    },
                    {
                        field: "okQuantity",
                        title: "总合格数",
                        align: "center"
                    },
                    {
                        field: "noOkQuantity",
                        title: "不合格数",
                        align: "center"
                    },
                    {
                        field: "inWarehouseQuantity",
                        title: "入库数",
                        align: "center"
                    },
                    {
                        field: "completionRate",
                        title: "达成率",
                        align: "center"
                    },
                    {
                        field: "createTime",
                        title: "开始生产日期",
                        align: "center"
                    },
                    // {
                    //     title: "操作",
                    //     align: "center",
                    //     fixed: "right",
                    //     toolbar: "#productionProgressTabBar"
                    // }
                ]
            ]

        });
        table.render({
            elem: "#processReportDetailTable",
            data: [],
            cols: [[
                {
                    field: "processName",
                    title: "工序名称",
                    align: "center"
                },
                {
                    field: "productionPlanQuantity",
                    title: "计划数量",
                    align: "center"
                },
                {
                    field: "okQuantity",
                    title: "合格数",
                    align: "center"
                },
                {
                    field: "noOkQuantity",
                    title: "不合格数",
                    align: "center"
                },
                {
                    field: "canGetQuantity",
                    title: "可领用数",
                    align: "center"
                },
                {
                    field: "reportedQuantity",
                    title: "总报工数",
                    align: "center"
                },
                {
                    field: "processCompletionRate",
                    title: "达成率",
                    align: "center"
                },
                {
                    field: "createTime",
                    title: "开始生产日期",
                    align: "center"
                },
            ]
            ]   })
        table.render({
            elem: "#planRecordReportDetailTable",
            data: [],
            cols: [
                [{
                    field: "planRecordId",
                    title: "制造令id",
                    align: "center"
                },
                {
                    field: "planRecordCode",
                    title: "制造令编号",
                    align: "center"
                },
                {
                    field: "planCode",
                    title: "生产计划编号",
                    align: "center"
                },
                {
                    field: "productionPlanQuantity",
                    title: "排产数",
                    align: "center"
                },
                {
                    field: "reportedQuantity",
                    title: "报工数",
                    align: "center"
                },
                {
                    field: "okQuantity",
                    title: "合格数",
                    align: "center"
                },
                {
                    field: "noOkQuantity",
                    title: "不合格数",
                    align: "center"
                },
                {
                    field: "inWarehouseQuantity",
                    title: "入库数",
                    align: "center"
                },
                {
                    field: "planRecordCompletionRate",
                    title: "达成率",
                    align: "center"
                },
                {
                    field: "createTime",
                    title: "开始排产日期",
                    align: "center"
                },
                
                ]
            ]
        })
        admin.req('production/productionPlan/admin/productionProgress/detail/' + nowData.data.productDetailId, {}, (res) => {
            console.log(res);
            if (res.code == 200) {
                table.reload('processReportDetailTable', {
                    data: res.data.processReportDetailVo
                })
                table.reload('planRecordReportDetailTable', {
                    data: res.data.planRecordReportDetailVos
                })
            }
        })
    });
</script>